#
#  Copyright (c) 2024 Huawei Device Co., Ltd.
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)

# project
project(Tetrahedron)

set(NATIVE_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
ADD_DEFINITIONS(-DVK_USE_PLATFORM_OHOS=1)

# include directory
include_directories(${NATIVE_ROOT_PATH}
                    ${NATIVE_ROOT_PATH}/include
                    ${NATIVE_ROOT_PATH}/include/util
                    ${NATIVE_ROOT_PATH}/third_party/glm
                    ${NATIVE_ROOT_PATH}/third_party)

# build shared library
add_library(tetrahedron_napi SHARED
            module.cpp
            app_napi.cpp
            tetrahedron.cpp
            frame_handle.cpp
            napi_manager.cpp
            napi_util.cpp
            CreateShaderModule.cpp
            vulkan_wrapper.cpp)

# 查找必要的库
find_library(ace-lib ace_ndk.z REQUIRED)
find_library(hilog-lib hilog_ndk.z REQUIRED)
find_library(napi-lib ace_napi.z REQUIRED)
find_library(rawfile-lib rawfile.z REQUIRED)
find_library(uv-lib uv REQUIRED)
find_library(vulkan-lib vulkan REQUIRED)
find_library(native-window-lib native_window REQUIRED)

# 设置链接库列表（移除重复的库）
set(sample_link_library
    ${ace-lib}
    ${hilog-lib}
    ${rawfile-lib}
    ${napi-lib}
    ${uv-lib}
    ${vulkan-lib}
    ${native-window-lib}
    libc++.a
    z
)

# 链接库到目标
target_link_libraries(tetrahedron_napi PUBLIC ${sample_link_library})
